//
//  NSURL+Extension.m
//  AFHttps
//
//  Created by sanmi on 2017/10/28.
//  Copyright © 2017年 吴喜超. All rights reserved.
//

#import "NSURL+Extension.h"

@implementation NSURL (Extension)

/**
 图片str转url
 @param serveUrl 服务器地址
 @param imageUrl 拼接图片地址
 @return url
 */
+ (NSURL *)serverUrlWithServeUrl:(NSString*)serveUrl ImageUrl:(NSString *)imageUrl
{
    if ([NSString isEmpty:imageUrl]) {
        return nil;
    }
    if ([NSString validateContainChineseWith:imageUrl]) {
        imageUrl = [imageUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
    }
    
    if ( [imageUrl containsString:@"http"]) {
        return [NSURL URLWithString:imageUrl];
    }else {
        return [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",serveUrl,imageUrl]];
    }
}
@end
